home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
Updates, etc.
/
PG PRO⁄PG Lite Demos
/
PG Writer π
/
PG Writer.MAIN
< prev
next >
Wrap
Text File
|
1994-03-28
|
8KB
|
296 lines
'===============================================================================
'= Copyright 1992 Staz™ Software, Inc. =
'= All rights reserved =
'= "Project.MAIN" from PG:PRO =
'===============================================================================
RESOURCES "PG Writer.RSRC","APPLpG3!"
COMPILE 1,140'set by PG:PRO
WINDOW OFF : WIDTH -2'standard
'
'{PG3} <-- PG PRO uses these as a source code markers. Do not remove them.
GLOBALS "PG PRO.GLBL"
GLOBALS "PG Writer.GLBL"
END GLOBALS
EDIT = 2'set EDIT/PICTURE FIELD border
INCLUDE "PG PRO.INCL"
SEGMENT
INCLUDE "PG Writer.INCL"
SEGMENT
INCLUDE "Edit Menu.FLTR"
INCLUDE "Font.FLTR"
'{PG4}
'===============================================================================
"@Filters":SEGMENT: REM Use the area below for additional filters
'-------------------------------------------------------------------------------
'===============================================================================
SELECT gAction'primary branch
'---------------------------------------------------------------------------
CASE _mainAction :GOSUB "Action:Main"'appl level events
CASE _menuAction :GOSUB "Action:Menu"'menu actions
CASE _buttonAction :GOSUB "Action:Button"'button clicked
CASE _mouseAction :GOSUB "Action:Mouse"'mouse down in whichClass
CASE _windowAction :GOSUB "Action:Window"'window actions
CASE _fieldAction :GOSUB "Action:Field"'edit fields actions
CASE _otherAction :GOSUB "Action:Other"'low level events
END SELECT:RETURN'end of primary selection
'===============================================================================
"@Includes":SEGMENT: REM Use the area below for additional ".INCL" files
'-------------------------------------------------------------------------------
'===============================================================================
"@Long Functions":SEGMENT: REM Put your application's long functions below
'-------------------------------------------------------------------------------
LOCAL FN fixMenuBar
setColorTo = _disable
LONG IF gActiveWnd = _docWnd
setMenusTo = _enable
IF SYSTEM(_crntDepth) > 2 THEN setColorTo = _enable
XELSE
setMenusTo = _disable
gSaveName$ = ""
END IF
MENU _fontMenu ,0,setMenusTo
MENU _sizeMenu ,0,setMenusTo
MENU _styleMenu ,0,setMenusTo
MENU _colorMenu ,0,setColorTo
END FN
'===============================================================================
LOCAL FN fixMenuItems
LONG IF gActiveWnd = _docWnd
MENU _fileMenu,_openItem ,_disable
MENU _fileMenu,_newItem ,_disable
MENU _fileMenu,_closeItem,_enable
LONG IF WINDOW(_EFTextLen)
MENU _fileMenu,_printItem,_enable
XELSE
MENU _fileMenu,_printItem,_disable
END IF
XELSE
MENU _fileMenu,_openItem ,_enable
MENU _fileMenu,_newItem ,_enable
MENU _fileMenu,_closeItem,_disable
MENU _fileMenu,_printItem,_disable
END IF
END FN
'===============================================================================
LOCAL FN saveFile
GET FIELD fldHndl&,_docFld
DEF OPEN "mTxtmRit"
OPEN "R",#1,gSaveName$,,gSaveVol
WRITE FIELD #1,fldHndl&
CLOSE #1
gDirty = _false
CALL SETWTITLE(WINDOW(_wndpointer),gSaveName$)
END FN
'===============================================================================
LOCAL FN openFile
gSaveName$ = gOpenName$
gSaveVol = gOpenVol
gDirty = _false
fldHndl& = 0
OPEN "R",#1,gSaveName$,1,gSaveVol
LONG IF gFileType& = _"TEXT"
lgth& = LOF(1)
IF lgth& > 32000 THEN lgth& = 32000
fldHndl& = FN NEWHANDLE(lgth&+2)
LONG IF fldHndl&
READ FILE #1,[fldHndl&]+2,lgth&
% [fldHndl&],lgth&
END IF
XELSE
READ FIELD #1,fldHndl&
END IF
CLOSE #1
LONG IF fldHndl&
FN pGbuild(_docWnd)
EDIT FIELD _docFld,&fldHndl&
DEF DISPOSEH (fldHndl&)
CALL SETWTITLE(WINDOW(_wndpointer),gSaveName$)
END IF
END FN
'===============================================================================
LOCAL FN printFile
DIM my,mx
DIM t,l,b,r
CURSOR _arrowCursor
DEF LPRINT
LONG IF PRCANCEL = _false
CURSOR _watchCursor
t;8 = [PRHANDLE] + _prInfo + _rPage
GET FIELD b4Print&,_docFld
oldStart = WINDOW(_selStart)
oldEnd = WINDOW(_selEnd)
WHILE WINDOW(_EFTextLen)
my = b:mx = l-1
theChar = FN TEGETOFFSET(my,TEHANDLE(_docFld))
SETSELECT 0,theChar
CALL TECUT(TEHANDLE(_docFld))
CALL OFFSETRECT(t,-5000,0)
EDIT FIELD -1,,@t,_statnoframed
CALL TESTYLPASTE(TEHANDLE(1))
GET FIELD tempHndl&,1
EDIT FIELD CLOSE 1
CALL OFFSETRECT(t,5000,0)
ROUTE #128
EDIT FIELD -1,&tempHndl&,@t,_statnoframed
KILL FIELD tempHndl&
ROUTE#0
LONG IF WINDOW(_EFTextLen)
CLEAR LPRINT
XELSE
CLOSE LPRINT
END IF
WEND
EDIT$(_docFld) = &b4Print&
SETSELECT oldStart,oldEnd
KILL FIELD b4Print&
END IF
END FN
'===============================================================================
"Action:Main"
'-------------------------------------------------------------------------------
SELECT gSubAction
CASE _mainStart
gOpenType$ = "TEXTmTxt"
gFixMenubar = _zTrue
CASE _mainOpen
FN openFile
CASE _mainSave
FN saveFile
CASE _mainPrint
FN openFile
FN printFile
FN pGclose(_docWnd)
CASE _mainTimer
CASE _mainShutDown
END SELECT:RETURN
'===============================================================================
"Action:Menu"
'-------------------------------------------------------------------------------
SELECT gWhichMenu
CASE _appleResMenu
FN pGbuild(-_splashWnd)
CASE _fileMenu
SELECT gWhichItem
CASE _newItem
gSaveName$ = "Untitled"
FN pGbuild(_docWnd)
gDirty = _false
CASE _pageSetupItem
DIALOG = _fixPageMessage
CASE _printItem
FN printFile
END SELECT
CASE _colorMenu
mHndl& = FN GETMHANDLE(_colorMenu)
LONG IF mHndl&
CALL GETITEM(mHndl&,1,t$):red = VAL(t$)
CALL GETITEM(mHndl&,2,t$):green = VAL(t$)
CALL GETITEM(mHndl&,3,t$):blue = VAL(t$)
EDIT TEXT ,,,,red,green,blue
END IF
END SELECT:RETURN
'===============================================================================
"Action:Button"
'-------------------------------------------------------------------------------
SELECT gWhichClass
END SELECT:RETURN
'===============================================================================
"Action:Mouse"
'-------------------------------------------------------------------------------
SELECT gWhichClass
END SELECT:RETURN
'===============================================================================
"Action:Window"
'-------------------------------------------------------------------------------
SELECT gSubAction
CASE _windowClose
gFixMenubar = _zTrue
LONG IF gDirty
t$ = gSaveName$
CALL PARAMTEXT(t$,"closing","","")
FN pGcntrRes(_"ALRT",132)
whichAlertBtn = FN ALERT(132,0)
SELECT whichAlertBtn
CASE 1:'save
FN pGautoMenu(_fileMenu,_saveAsItem)
CASE 2:'don't save
CASE 3:'cancel
gFixMenubar = _false
gAction = 0
END SELECT
END IF
CASE _windowUpdate
CASE _windowActivate :gFixMenubar = _zTrue
CASE _windowDeactivate:gFixMenubar = _zTrue
CASE _windowSized
CASE _windowMoved
CASE _windowClicked
CASE _windowWillZoomOut
CASE _windowWillZoomIn
CASE _windowWillGrow
CASE _windowDocWillMove
END SELECT:RETURN
'===============================================================================
"Action:Field"
'-------------------------------------------------------------------------------
SELECT gSubAction
CASE _fieldActivate
CASE _fieldChanging
CASE _fieldKeyPressed
gDirty = _zTrue
CASE _fieldReturn
CASE _fieldTab
CASE _fieldShiftTab
CASE _fieldClear
CASE _fieldLeft
CASE _fieldRight
CASE _fieldUp
CASE _fieldDown
CASE _fieldClicked
END SELECT:RETURN
'===============================================================================
"Action:Other"
'-------------------------------------------------------------------------------
SELECT gSubAction
CASE _otherDisk:gAction=0 : REM Prevents SFOpen dialog on disk insert
CASE _otherSwitch
CASE _otherScrap
CASE _otherCursor
CASE _otherKeyPressed
CASE _otherBeforeMenu
FN fixMenuItems
CASE _otherNullEvent
LONG IF gFixMenubar
gFixMenubar = _false
FN fixMenuBar
END IF
CASE _otherFilterEvent
CASE _otherUser
LONG IF gDialogValue = _fixPageMessage
CLS
FN pGfixEditor
END IF
CASE _otherUserInit
CASE _otherUserUpdate
CASE _otherUserClick
CASE _otherUserDispose
END SELECT:RETURN
'===============================================================================
"@Subroutines":SEGMENT: REM Put your application's subroutines below
'-------------------------------------------------------------------------------
'===============================================================================